<html>
  <script type="text/javascript">
    function getUrlVars() {
      var vars = {};
      var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = unescape(value);
      });
      return vars;
    }

    function checkLogin() {
      var iframe = document.getElementsByTagName("iframe")[0],
          innerDoc = iframe.contentDocument || iframe.contentWindow.document;
      // weak validation: relies on the fact that cas/login page has a body id="cas":
      var loggedIn = !!!(innerDoc.getElementById("cas"));

      var url = getUrlVars().url;
      if (!url) {
        url = "/";
      } 
      if(url[0] != "/"){
        url = '/'+url;
      }
      window.location = url;
    }
  </script>
  <body>
    <div id="login">
      Loading credentials..
    </div>
    <iframe id="iframe" src="/testPage?login" onload="checkLogin()" style="display:none" width="0" height="0"/>
  </body>
</html>
